Skip to content

连接远程服务端 - ConnectRemote

函数简介

A 端 配置远程调用参数并建立与 B 端服务的连接。并在连接、CreateInstance 之后自动在 B 端执行 Reg(注册到后台)。

接口名称

ConnectRemote

DLL调用

c
int32_t ConnectRemote(int64_t instance, char* host, int32_t port,
                      char* token, int32_t timeoutMs);

参数说明

参数名类型说明
instance长整数型OLAPlug 对象指针,由 CreateCOLAPlugInterFace 接口生成。
host字符串B 端服务 IP 或域名。
port整数型B 端监听端口(与 启动远程调度服务 - StartRemoteServer 一致)。
token字符串鉴权令牌(需与 B 端 StartRemoteServertoken 一致;
timeoutMs整数型单次远程调用超时(毫秒);0 表示使用默认 5000 ms。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.ConnectRemote("127.0.0.1", 9000, "token");
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.ConnectRemote("127.0.0.1", 9000, "token");
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.ConnectRemote("127.0.0.1", 9000, "token")
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.ConnectRemote("127.0.0.1", 9000, "token");
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.ConnectRemote("127.0.0.1", 9000, "token")
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.ConnectRemote("127.0.0.1", 9000, "token")
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.ConnectRemote(“127.0.0.1“, 9000, “token“)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.ConnectRemote("127.0.0.1", 9000, "token");
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.ConnectRemote("127.0.0.1", 9000, "token")
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.ConnectRemote("127.0.0.1", 9000, "token");

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
ConnectRemote(instance, "127.0.0.1", 9000, "token");
csharp
long instance = CreateCOLAPlugInterFace();
ConnectRemote(instance, "127.0.0.1", 9000, "token");
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ConnectRemote(instance, "127.0.0.1", 9000, "token")

返回值

1 成功,0 失败。

注意事项